// packageStore/pages/purchase/orderDeliveryInfo/orderDeliveryInfo.js
const app = getApp()
const componentBehavior = require('../../../../js/common/ComponentBehavior')

import {
  api,
  util,
} from '../../../../js/util'

Page({
  behaviors: [componentBehavior],
  /**
   * 页面的初始数据
   */
  data: {
    imgDomain: api.imgDomain,
    enableOss: api.enableOss,
    mainColor: api.titleColor || "#e56b14", //主题色
    list: [], // 订单发货信息列表
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setNavigationBarColor({
      backgroundColor: api.titleColor || "#e56b14", //主题色,
      frontColor: '#ffffff',
    })
    this.getPrevPageData()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
  
  getPrevPageData () {
    let pages = getCurrentPages()
    let prevPage = pages[pages.length - 2]
    let list = prevPage.data.DispatchInfo || []
    let consignee = prevPage.data.consignee || {}
    let OrderInfo = prevPage.data.OrderInfo || {}
    this.setData({
      list,
      consignee,
      OrderInfo
    })
  },

    /**
   * 点击查看凭证大图
   */
  showbigImg: function (event) {
    var that = this;
    var index = event.currentTarget.dataset.index;
    var srcs = event.currentTarget.dataset.srcs;
    var type = event.currentTarget.dataset.type;
    if(type == 1){
      for(var i=0;i<srcs.length;i++){
        srcs[i] = that.data.imgDomain + srcs[i]
      }
    }
    //图片预览
    wx.previewImage({
      current: srcs[index], // 当前显示图片的http链接
      urls: srcs // 需要预览的图片http链接列表
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },
})